using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace ns20
{
	internal static class Class192
	{
		public static bool smethod_0<T>(ICollection<T> icollection_0)
		{
			if (icollection_0 != null)
			{
				return icollection_0.Count == 0;
			}
			return true;
		}

		public static void smethod_1<T>(this IList<T> ilist_0, IEnumerable<T> ienumerable_0)
		{
			if (ilist_0 == null)
			{
				throw new ArgumentNullException("initial");
			}
			if (ienumerable_0 == null)
			{
				return;
			}
			foreach (T item in ienumerable_0)
			{
				ilist_0.Add(item);
			}
		}

		public static bool smethod_2(Type type_0)
		{
			Class204.smethod_2(type_0, "type");
			if (typeof(IDictionary).IsAssignableFrom(type_0))
			{
				return true;
			}
			if (Class195.smethod_13(type_0, typeof(IDictionary<, >)))
			{
				return true;
			}
			return false;
		}

		public static ConstructorInfo smethod_3(Type type_0, Type type_1)
		{
			Type type = typeof(IEnumerable<>).MakeGenericType(type_1);
			ConstructorInfo[] constructors = type_0.GetConstructors(BindingFlags.Instance | BindingFlags.Public);
			int num = 0;
			ConstructorInfo constructorInfo;
			while (true)
			{
				if (num < constructors.Length)
				{
					constructorInfo = constructors[num];
					IList<ParameterInfo> parameters = constructorInfo.GetParameters();
					if (parameters.Count == 1 && type.IsAssignableFrom(parameters[0].ParameterType))
					{
						break;
					}
					num++;
					continue;
				}
				return null;
			}
			return constructorInfo;
		}

		public static bool smethod_4<T>(this IList<T> ilist_0, T gparam_0)
		{
			return ilist_0.smethod_5(gparam_0, EqualityComparer<T>.Default);
		}

		public static bool smethod_5<T>(this IList<T> ilist_0, T gparam_0, IEqualityComparer<T> iequalityComparer_0)
		{
			if (ilist_0.smethod_6(gparam_0, iequalityComparer_0))
			{
				return false;
			}
			ilist_0.Add(gparam_0);
			return true;
		}

		public static bool smethod_6<T>(this IEnumerable<T> ienumerable_0, T gparam_0, IEqualityComparer<T> iequalityComparer_0)
		{
			if (iequalityComparer_0 == null)
			{
				iequalityComparer_0 = EqualityComparer<T>.Default;
			}
			if (ienumerable_0 == null)
			{
				throw new ArgumentNullException("source");
			}
			foreach (T item in ienumerable_0)
			{
				if (iequalityComparer_0.Equals(item, gparam_0))
				{
					return true;
				}
			}
			return false;
		}

		public static bool smethod_7<T>(this IList<T> ilist_0, IEnumerable<T> ienumerable_0, IEqualityComparer<T> iequalityComparer_0)
		{
			bool result = true;
			foreach (T item in ienumerable_0)
			{
				if (!ilist_0.smethod_5(item, iequalityComparer_0))
				{
					result = false;
				}
			}
			return result;
		}

		public static int smethod_8<T>(this IEnumerable<T> ienumerable_0, Func<T, bool> func_0)
		{
			int num = 0;
			foreach (T item in ienumerable_0)
			{
				if (!func_0(item))
				{
					num++;
					continue;
				}
				return num;
			}
			return -1;
		}

		public static int smethod_9<T>(this IEnumerable<T> ienumerable_0, T gparam_0, IEqualityComparer<T> iequalityComparer_0)
		{
			int num = 0;
			foreach (T item in ienumerable_0)
			{
				if (!iequalityComparer_0.Equals(item, gparam_0))
				{
					num++;
					continue;
				}
				return num;
			}
			return -1;
		}

		private static IList<int> smethod_10(IList ilist_0)
		{
			IList<int> list = new List<int>();
			IList list2 = ilist_0;
			while (true)
			{
				list.Add(list2.Count);
				if (list2.Count == 0)
				{
					break;
				}
				object obj = list2[0];
				if (!(obj is IList))
				{
					break;
				}
				list2 = (IList)obj;
			}
			return list;
		}

		private static void smethod_11(IList ilist_0, Array array_0, int[] int_0)
		{
			int num = int_0.Length;
			if (num == array_0.Rank)
			{
				array_0.SetValue(smethod_12(ilist_0, int_0), int_0);
				return;
			}
			int length = array_0.GetLength(num);
			IList list = (IList)smethod_12(ilist_0, int_0);
			int count = list.Count;
			if (count != length)
			{
				throw new Exception("Cannot deserialize non-cubical array as multidimensional array.");
			}
			int[] array = new int[num + 1];
			for (int i = 0; i < num; i++)
			{
				array[i] = int_0[i];
			}
			for (int j = 0; j < array_0.GetLength(num); j++)
			{
				array[num] = j;
				smethod_11(ilist_0, array_0, array);
			}
		}

		private static object smethod_12(IList ilist_0, int[] int_0)
		{
			IList list = ilist_0;
			int num = 0;
			int index;
			while (true)
			{
				if (num < int_0.Length)
				{
					index = int_0[num];
					if (num == int_0.Length - 1)
					{
						break;
					}
					list = (IList)list[index];
					num++;
					continue;
				}
				return list;
			}
			return list[index];
		}

		public static Array smethod_13(IList ilist_0, Type type_0, int int_0)
		{
			IList<int> list = smethod_10(ilist_0);
			while (list.Count < int_0)
			{
				list.Add(0);
			}
			Array array = Array.CreateInstance(type_0, list.ToArray());
			smethod_11(ilist_0, array, new int[0]);
			return array;
		}
	}
}
